package edu.szu.huhanpeng.doodlingFight.model.data 
{
	import edu.szu.huhanpeng.doodlingFight.interfaces.IChessData;
	import edu.szu.huhanpeng.doodlingFight.interfaces.IChessFriend;
	
	/**
	 * chessData的friend属性，引用周围的同类棋子
	 * @author Huhanpeng
	 */
	public class ChessFriend implements IChessFriend 
	{
		private var _num:int = 0;	//同类数
		
		private var _up:IChessData;
		private var _down:IChessData;
		private var _left:IChessData;
		private var _right:IChessData;
		private var _LU:IChessData;
		private var _RU:IChessData;
		private var _LD:IChessData;
		private var _RD:IChessData;
		
		public function ChessFriend() 
		{
			
		}
		
		/* INTERFACE edu.szu.huhanpeng.doodlingFight.interfaces.IChessFriend */
		
		public function reset():void
		{
			_up =			
			_down=
			_left=
			_right=
			_LU=
			_RU=
			_LD=
			_RD = null;
			
			_num = 0;
		}
		
		public function get num():int 
		{
			return _num;
		}
		
		public function get up():IChessData 
		{
			return _up;
		}
		
		public function set up(value:IChessData):void 
		{
			if (value == null && _up != null) 
			{
				_num--;
			}
			else if ( value != null && _up == null) 
			{
				_num++;
			}
			
			_up = value;
		}
		
		public function get down():IChessData 
		{
			return _down;
		}
		
		public function set down(value:IChessData):void 
		{
			if (value == null && _down != null) 
			{
				_num--;
			}
			else if ( value != null && _down == null) 
			{
				_num++;
			}
			
			_down = value;
		}
		
		public function get left():IChessData 
		{
			return _left;
		}
		
		public function set left(value:IChessData):void 
		{
			if (value == null && _left != null) 
			{
				_num--;
			}
			else if ( value != null && _left == null) 
			{
				_num++;
			}
			
			_left = value;
		}
		
		public function get right():IChessData 
		{
			return _right;
		}
		
		public function set right(value:IChessData):void 
		{
			if (value == null && _right != null) 
			{
				_num--;
			}
			else if ( value != null && _right == null) 
			{
				_num++;
			}
			
			_right = value;
		}
		
		public function get LU():IChessData 
		{
			return _LU;
		}
		
		public function set LU(value:IChessData):void 
		{
			if (value == null && _LU != null) 
			{
				_num--;
			}
			else if ( value != null && _LU == null) 
			{
				_num++;
			}
			
			_LU = value;
		}
		
		public function get RU():IChessData 
		{
			return _RU;
		}
		
		public function set RU(value:IChessData):void 
		{
			if (value == null && _RU != null) 
			{
				_num--;
			}
			else if ( value != null && _RU == null) 
			{
				_num++;
			}
			
			_RU = value;
		}
		
		public function get LD():IChessData 
		{
			return _LD;
		}
		
		public function set LD(value:IChessData):void 
		{
			if (value == null && _LD != null) 
			{
				_num--;
			}
			else if ( value != null && _LD == null) 
			{
				_num++;
			}
			
			_LD = value;
		}
		
		public function get RD():IChessData 
		{
			return _RD;
		}
		
		public function set RD(value:IChessData):void 
		{
			if (value == null && _RD != null) 
			{
				_num--;
			}
			else if ( value != null && _RD == null) 
			{
				_num++;
			}
			
			_RD = value;
		}
		
	}

}